<?php
class Location_Model_Materiel extends Zend_Db_Table_Abstract
{
	protected $_name = 'location_materiel';

	public function insert(array $data)
	{
		//TODO : code to clean data before insert here
		parent::insert($data);
	}

	public function update(array $data, $where)
	{
		//TODO : code to clean data before update here
		parent::update($data, $where);
	}

	public function fetchById($id)
	{
		$row = $this->find((int)$id)->current()->toArray();
		return $row;
	}

	public function deleteById($id)
	{
		return $this->delete('id = '.(int)$id);
	}

	public function fetchAllByCategoryId($categoryId, array $options = null)
	{
		if(!is_numeric($categoryId)) return false;
		
		//TODO : if is connected
		return $this->fetchAll(array('category_id = ?'=>$categoryId,'isvisible'=>1))->toArray();
	
		
		//TODO else 'isvisible = 1'
		//return parent::fetchAll(array('isvisible = 1','category_id = ?'=>$categoryId))->toArray();
	}
}
